package com.hq.fxh.No6UerSpace.Activity;

import android.content.Intent;
import android.graphics.Color;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hq.fxh.CustomerView.CircleImageView;
import com.hq.fxh.CustomerView.MyViewPager;
import com.hq.fxh.CustomerView.countview.RiseNumberTextView;
import com.hq.fxh.No0_ChengQu.Activity.BaseActivity;
import com.hq.fxh.No6UerSpace.Adapter.Padpter_Space;
import com.hq.fxh.No6UerSpace.Fragment.Fragment_HuoDong;
import com.hq.fxh.No6UerSpace.Fragment.Fragment_UserSpace_Plate;
import com.hq.fxh.No6UerSpace.Fragment.Fragment_UserSpace_Video;
import com.hq.fxh.R;
import com.hq.fxh.Utils.LogUtils;

import java.util.Arrays;


public class Space_CompanyActivity extends BaseActivity implements Padpter_Space.TabPagerListener, View.OnClickListener {


    protected MyViewPager viewpager;
    protected CircleImageView imageUserSpaceHeadPic;
    protected TextView tvUserSpaceName;
    protected TextView tvUserSpaceJieShao;
    protected RiseNumberTextView tvSpaceTieNum;
    protected LinearLayout layoutSpaceTie;
    protected RiseNumberTextView tvSpaceGuanzhuNum;
    protected LinearLayout layoutSpaceGuanzhu;
    protected RiseNumberTextView tvSpaceFensiNum;
    protected LinearLayout layoutSpaceFenSi;
    protected Toolbar toolbar;
    protected CollapsingToolbarLayout collapsingToolbar;
    protected TabLayout tabLayout;
    protected AppBarLayout appbar;
    private Padpter_Space adapter;


    @Override
    protected int getLayoutId() {
        return R.layout.activity_space_company;
    }

    @Override
    protected void initView() {
        viewpager = (MyViewPager) findViewById(R.id.viewpager);
        imageUserSpaceHeadPic = (CircleImageView) findViewById(R.id.image_UserSpace_HeadPic);
        tvUserSpaceName = (TextView) findViewById(R.id.tv_UserSpace_Name);
        tvUserSpaceJieShao = (TextView) findViewById(R.id.tv_UserSpace_JieShao);
        tvSpaceTieNum = (RiseNumberTextView) findViewById(R.id.tv_Space_TieNum);
        layoutSpaceTie = (LinearLayout) findViewById(R.id.layout_Space_Tie);
        layoutSpaceTie.setOnClickListener(Space_CompanyActivity.this);
        tvSpaceGuanzhuNum = (RiseNumberTextView) findViewById(R.id.tv_Space_guanzhuNum);
        layoutSpaceGuanzhu = (LinearLayout) findViewById(R.id.layout_Space_Guanzhu);
        layoutSpaceGuanzhu.setOnClickListener(Space_CompanyActivity.this);
        tvSpaceFensiNum = (RiseNumberTextView) findViewById(R.id.tv_Space_fensiNum);
        layoutSpaceFenSi = (LinearLayout) findViewById(R.id.layout_Space_FenSi);
        layoutSpaceFenSi.setOnClickListener(Space_CompanyActivity.this);
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsingToolbar);
        tabLayout = (TabLayout) findViewById(R.id.tabLayout);
        appbar = (AppBarLayout) findViewById(R.id.appbar);


    }

    @Override
    protected void initData() {
        viewpager.setOffscreenPageLimit(5);
        collapsingToolbar.setBackgroundResource(R.color.white);
        collapsingToolbar.setExpandedTitleColor(Color.parseColor("#00ffffff"));//设置还没收缩时状态下字体颜色
        collapsingToolbar.setCollapsedTitleGravity(Gravity.CENTER);
        adapter = new Padpter_Space(getSupportFragmentManager()
                , 6, Arrays.asList("帖子", "视频", "产品", "案例", "招聘", "活动"), this);
        adapter.setListener(this);
        viewpager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewpager);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    @Override
    public Fragment getFragment(int position) {
        switch (position) {
            case 0:
                return Fragment_UserSpace_Plate.newInstance();

            case 1:
                return Fragment_UserSpace_Video.newInstance(1);
            case 2:
                return Fragment_UserSpace_Video.newInstance(2);
            case 3:
                return Fragment_UserSpace_Video.newInstance(3);
            case 4:
                return Fragment_UserSpace_Video.newInstance(4);
            case 5:
                return Fragment_UserSpace_Video.newInstance(5);
            default:
                return Fragment_HuoDong.newInstance();

        }
    }

    @Override
    public void onClick(View view) {
        Intent intent = new Intent(Space_CompanyActivity.this, SpaceGuanZhuActivity.class);
        LogUtils.e("dianji时间");
       if (view.getId() == R.id.layout_Space_Tie) {
            intent.putExtra("type", 0);
        } else if (view.getId() == R.id.layout_Space_Guanzhu) {
            intent.putExtra("type", 1);
        } else if (view.getId() == R.id.layout_Space_FenSi) {
            intent.putExtra("type", 2);
        }

        startActivity(intent);
    }


}
